Fix bug where transaction fires multiple events.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 26 Jul 2005 15:24:28 +0000 (15:24 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 26 Jul 2005 15:24:28 +0000 (15:24 +0000)
Add general trace() call to help future debugging.
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/xenstore/testsuite/08transaction.sh
tools/xenstore/xenstored_core.c
tools/xenstore/xenstored_core.h
tools/xenstore/xenstored_watch.c

index 4c786df68756a7d4e57ebd0e5d4b61850019c467..20cd36f6230717b48a8a07d5f6b9769eb1d390e6 100644 (file)
@@ -79,3 +79,15 @@ FATAL: 1: commit: Connection timed out" ]
 2 async commit
 1 waitwatch
 1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/dir/sub:token" ]
+
+# Multiple events from single transaction don't trigger assert
+[ "`echo -e '1 watch /test token
+2 start /test
+2 write /test/1 create contents
+2 write /test/2 create contents
+2 async commit
+1 waitwatch
+1 ackwatch token
+1 waitwatch
+1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/1:token
+1:/test/2:token" ]
index 3689ea4b569024a6fc814365bb3f8a2f91d31e49..3bf63314b75f5e3623f26c32b1b64f8e5362f27e 100644 (file)
@@ -111,6 +111,8 @@ void __attribute__((noreturn)) corrupt(struct connection *conn,
        str = talloc_vasprintf(NULL, fmt, arglist);
        va_end(arglist);
 
+       trace("xenstored corruption: connection id %i: err %s: %s",
+               conn ? (int)conn->id : -1, strerror(saved_errno), str);
        eprintf("xenstored corruption: connection id %i: err %s: %s",
                conn ? (int)conn->id : -1, strerror(saved_errno), str);
 #ifdef TESTING
@@ -230,6 +232,21 @@ static void trace_blocked(const struct connection *conn,
        write(tracefd, ")\n", 2);
 }
 
+void trace(const char *fmt, ...)
+{
+       va_list arglist;
+       char *str;
+
+       if (tracefd < 0)
+               return;
+
+       va_start(arglist, fmt);
+       str = talloc_vasprintf(NULL, fmt, arglist);
+       va_end(arglist);
+       write(tracefd, str, strlen(str));
+       talloc_free(str);
+}
+
 static bool write_message(struct connection *conn)
 {
        int ret;
index 61d47b53425677ddacd7f89be073b8ee43dc055c..9643d36b9572cae7ce82c20e9db4373f85c7b6b4 100644 (file)
@@ -170,5 +170,6 @@ void *read_all(int *fd, unsigned int *size);
 void trace_create(const void *data, const char *type);
 void trace_destroy(const void *data, const char *type);
 void trace_watch_timeout(const struct connection *conn, const char *node, const char *token);
+void trace(const char *fmt, ...);
 
 #endif /* _XENSTORED_CORE_H */
index c532da26a846b1aa6ddd3eaeabe2ffa217e19594..a49dcbc954b007fd658e29e82fc9510f93db31ca 100644 (file)
@@ -134,8 +134,6 @@ bool fire_watches(struct connection *conn, const char *node, bool recurse)
        if (conn->transaction)
                return false;
 
-       assert(conn->state == OK);
-
        /* Create an event for each watch.  Don't send to self. */
        list_for_each_entry(i, &connections, list) {
                if (i == conn)